package com.lhy.ltss.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * @description:
 * 统一返回结果
 * @author: 李汇远
 */
public class ResultJson {

    private static final String CODE = "code";
    private static final int CODE_OK = 200;
    private static final int CODE_FAIL = 400;

    private static final String CONTENT = "content";

    private static JSONObject get(int code , Object content){
        JSONObject json = new JSONObject();
        json.put(CODE, code);
        json.put(CONTENT, content);
        return json;
    }

    public static JSONObject ok(Object content){
        return get(CODE_OK, content);
    }

    public static JSONObject ok(){
        return ok("ok");
    }

    public static JSONObject fail(Object content){
        return get(CODE_FAIL, content);
    }

    public static JSONObject fail(){
        return fail("fail");
    }


}
